const path = require("path");
const polyfill = require("./webpack-plugin-polyfill/index");
// cryptojs-browserify
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\crypto-browserify-master\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\crypto-browserify.js";

// jsonwebtoken;
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\node-jsonwebtoken-master\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\jsonwebtoken.js";

// // cryptojs - browserify;
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\global-var-test";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\global-var-test.js";

// newsie
var input =
  "C:\\Users\\Administrator\\Desktop\\gitee\\n2o\\source\\newsie-master\\src\\index.ts";

// global-var-test
// var input =
//   "C:\\Users\\Administrator\\Desktop\\gitee\\n2o\\source\\global-var-test\\index.js";
module.exports = {
  entry: input,
  mode: "development",
  experiments: {
    outputModule: true,
  },
  devtool: false,
  output: {
    library: { type: "module" },
    // globalObject: "this",
    path: path.resolve(__dirname, "dist/webpack-dist"),
    filename:
      "global-var.js" ||
      "newsie.js" ||
      "jsonwebtoken.development.js" ||
      "crypto-module-development.js",
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "ts-loader",
          },
        ],
      },
    ],
  },
  //   externalsType: "module",
  externals: [
    {
      // ohos_util: "@ohos.util",
      // ohos_process: "@ohos.process",
      // ohos_hilog: "@ohos.hilog",
      //   buffer: "buffer",
      //   process: "process",
      //   events: "events",
      //   string_decoder: "string_decoder",
      net: "net",

      tls: "tls",
      zlib: "zlib",
    },
    /^@ohos\..+/,
  ],
  plugins: [new polyfill()],

  resolve: {
    extensions: [".js", ".ts", ".esm.js"],
  },
};
